package com.slz3.business.module.configManagement.conVersion.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.configManagement.conVersion.domain.ConVersion;
import com.slz3.business.module.configManagement.conVersion.domain.ConVersionCondition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

@Component
public class ConVersionResController {

    @Autowired
    private ConVersionResAtomic atomic;

    public Mono<ServerResponse> add(ServerRequest req, ConVersion conVersion) {
        if (ConVersionResUnsafeValid.add(req, conVersion)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.add_$ConVersionUpdateLock(req, conVersion);
        }
    }

    public Mono<ServerResponse> delete(ServerRequest req, ConVersionCondition conVersionCondition) {
        if (ConVersionResUnsafeValid.delete(req, conVersionCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.delete_$ConVersionUpdateLock(req, conVersionCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, ConVersion conVersion) {
        if (ConVersionResUnsafeValid.modify(req, conVersion)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.modify_$ConVersionUpdateLock(req, conVersion);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (ConVersionResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
//        return conVersionResAtomic.info_$ConVersionUpdateLock(req);
        if (ConVersionResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.info_$ConVersionUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (ConVersionResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, ConVersionCondition conVersionCondition) {
        //
        if (ConVersionResUnsafeValid.auditSubmit(req, conVersionCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.auditSubmit_$ConVersionUpdateLock(req, conVersionCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, ConVersionCondition conVersionCondition) {
        if (ConVersionResUnsafeValid.audit(req, conVersionCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.audit_$ConVersionUpdateLock(req, conVersionCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, ConVersionCondition conVersionCondition) {
        if (ConVersionResUnsafeValid.auditReject(req, conVersionCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.auditReject_$ConVersionUpdateLock(req, conVersionCondition);
        }
    }

    public Mono<ServerResponse> usingEnable(ServerRequest req, ConVersionCondition conVersionCondition) {
        if (ConVersionResUnsafeValid.usingEnable(req, conVersionCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.usingEnable_$ConVersionUpdateLock(req, conVersionCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, ConVersionCondition conVersionCondition) {
        if (ConVersionResUnsafeValid.usingDisable(req, conVersionCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return atomic.usingDisable_$ConVersionUpdateLock(req, conVersionCondition);
        }
    }

}
